<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"    
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core">
   
<h:head>
	<title>Market Grabber - Manual Requests</title>
</h:head>

<h:body>
	<ui:composition template="./template.xhtml">
		<ui:define name="siteheader">
                Manual Requests
        </ui:define>
		<ui:define name="leftmenu">
    		<li><h:link outcome="inbox">Inbox</h:link></li>
		</ui:define>

		<ui:define name="maincontent">
		
			<p>If you manually requested offers (from suppliers without webservice-integration), 
			please document them here.</p>
			
			<br/>
		
			<h:form>
			
			<label for="supplier">Supplier: </label>
			<h:selectOneMenu value="#{manualOffers.supplier}">
				<f:selectItem itemValue="Supplier1" itemLabel="Supplier1" />
  				 <f:selectItem itemValue="Supplier2" itemLabel="Supplier2" />
   			</h:selectOneMenu><br/>
			
            <label for="amount">Amount: </label>
            <h:inputText value="#{manualOffers.amount}"/><br/>
            <label for="good">Good: </label>
            <h:inputText value="#{manualOffers.good}"/><br/>
            <label for="price">Price: </label>
            <h:inputText value="#{manualOffers.price}"/><br/>
            <h:commandButton value="Add" action="#{manualOffers.add}" />    
           
            <h:dataTable var="o" value="#{manualOffers.offers}">
                    <h:column>
                            <f:facet name="header">Supplier</f:facet>
                            <h:outputText value="#{o.supplier.name}"/>
                    </h:column>
                    
                    <h:column>
	                    <h:dataTable var="i" value="#{o.items}">
	                    <h:column>
	                    		  <f:facet name="header">Amount</f:facet>
	                            <h:outputText value="#{i.amount}"/>
	                    </h:column>
	                    <h:column>
	                            <f:facet name="header">Good</f:facet>
	                            <h:outputText value="#{i.good}"/>
	                    </h:column>
	                    <h:column>
	                            <f:facet name="header">Price</f:facet>
	                            <h:outputText value="#{i.price}"/>
	                    </h:column>	
	                    </h:dataTable>
                    </h:column>
                    <h:column>
                            <h:commandButton value="Delete" action="#{manualOffers.remove}">
                                    <f:setPropertyActionListener target="#{manualOffers.toDelete}" value="#{o}" />
                            </h:commandButton>
                    </h:column>
            </h:dataTable>
           
            <br/><br/>
           
            <h:commandButton value="Process step complete" action="#{manualOffers.done}"/>
                 
          </h:form>
							
		</ui:define>
	</ui:composition>
</h:body>
</html>
